<%--
  Created by IntelliJ IDEA.
  User: EDZ
  Date: 2018-5-25
  Time: 13:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>父级菜单Tree</title>
    <jsp:include page="/include/include.jsp"/>
    <link href="${pageContext.request.contextPath}/common/css/style.css?v=4.1.0"
          rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content">
                <div id="upMenuTree"></div>
            </div>
            <div class="form-group hidden">
                <div class="col-sm-12 col-sm-offset-12">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    $(document).ready(function () {
        getTreeData()
    });

    function getTreeData() {
        $.ajax({
            type: "post",
            url: "/sysRes/treeData",
            success: function (tree) {
                var treeTemp = JSON.parse(tree);
                loadTree(treeTemp);
            }
        });
    }

    function loadTree(tree) {
        $('#upMenuTree').jstree({
            'core': {
                'data': tree
            },
            "plugins": ["search"]
        });
        $('#upMenuTree').jstree().open_all();
    }

    $('#upMenuTree').on("changed.jstree", function (e, data) {
        if (data.node.id != -1) {
            parent.loadUpMenu(data.node.id, data.node.text);
            var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
            parent.layer.close(index);
        }
    });

</script>
</html>
